package com.jackiechancinema.ssm.controller;

import com.jackiechancinema.ssm.bo.SalaryBo;
import com.jackiechancinema.ssm.dto.SalaryDto;
import com.jackiechancinema.ssm.entity.Salary;
import com.jackiechancinema.ssm.service.Impl.SalaryServiceImpl;
import com.jackiechancinema.ssm.vo.PageVo;
import com.jackiechancinema.ssm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("salary/")
public class SalManageController {
    @Autowired
    private SalaryServiceImpl salaryService;
//    @GetMapping("salaryPage")
//    public PageVo<SalaryDto> salary(int page, int limit){
//        return salaryService.queryPage(page,limit);
//    }
    @GetMapping("salaryPage")
    public PageVo<SalaryDto> salary(SalaryBo bo){
    return salaryService.queryPage(bo);
}
    @PostMapping("delete")
    public R delete(int id){
        return salaryService.delete(id);
    }

    @PostMapping("update")
    public R update(SalaryDto salaryDto){
        return salaryService.updateSalary(salaryDto);
    }
    @PostMapping("save")
    public R save(Salary salary){
        return salaryService.save(salary);
    }
    @PostMapping("batchadd")
    public R saveBatch(MultipartFile file){
        return salaryService.batchAdd(file);
    }
    @GetMapping("download")
    public void download(SalaryBo bo, HttpServletResponse response){
        salaryService.exportExcel(bo,response);
    }
}
